import { Row, Col } from "antd";
import defaultData from "./data";
import types from "./types";
import Props from "../base/Props";
import { WeaDatePicker, WeaSelect,WeaLocaleProvider } from "ecCom";

const getLabel = WeaLocaleProvider.getLabel;
const { SPECIFICDATE, TODAYDATE } = types;

export default class DateProps extends Props {
  constructor(props) {
    super(props);

    this.state = {
      options: [{
        key: SPECIFICDATE,
        selected: true,
        showname: getLabel(503830, '特定日期')
      }, {
        key: TODAYDATE,
        showname: getLabel(503831, '填写当天'),
        selected: false
      }]
    };
  }

  renderDefaultValue() {
    const { data } = this.props;
    const { defaultValue, defaultValueType } = data;

    return (
      <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@gkog8h`} className='wea-edc-form-group'>
        <label>{getLabel(502451,'默认值')}</label>
        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@sv76qs`} span={8}>
          <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@33gmdk`}
            options={this.state.options}
            value={defaultValueType}
            onChange={this.handlePropChange('defaultValueType')}
          />
        </Col>
        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@kuzg7r`} offset={1} span={15}>
          {SPECIFICDATE !== defaultValueType ? null :
            <WeaDatePicker ecId={`${this && this.props && this.props.ecId || ''}_WeaDatePicker@xh3bzc`}
              value={defaultValue}
              formatPattern='2'
              onChange={this.handlePropChange('defaultValue')}
            />
          }
        </Col>
      </Row>
    );
  }
}

DateProps.defaultProps = {
  data: defaultData
};